use thiserror::Error;

#[derive(Error, Debug)]
pub enum MyError {
    #[error("custom error:{0}")]
    Msg(String),
    #[error("io error:{0}")]
    IoError(#[from] std::io::Error),
    #[error("serde json error:{0}")]
    SerdeJson(#[from] serde_json::Error),
    #[error("tokio error:{0}")]
    TokioError(#[from] tokio::task::JoinError),
}

impl MyError {
    pub fn custom(msg: &str) -> Self {
        MyError::Msg(msg.to_string())
    }
}

pub type MyResult<T> = std::result::Result<T, MyError>;
